Skip to content

chore: repo cleanups + start OpenCode in ~/dev - #1

Merged
MathurAditya724 merged 3 commits into
mainfrom
chore/repo-cleanup
Apr 28, 2026
Merged

chore: repo cleanups + start OpenCode in ~/dev#1
MathurAditya724 merged 3 commits into
mainfrom
chore/repo-cleanup

Conversation

@MathurAditya724

@MathurAditya724 MathurAditya724 commented Apr 28, 2026

Copy link
Copy Markdown
Member

Summary

Two related sets of changes:

1. Small repo cleanups (commit 612fcb8)

  • .dockerignore — drop the misleading Dockerfile entry (BuildKit reads the Dockerfile regardless of .dockerignore), explicitly exclude .env, and add common editor/OS noise patterns (.idea, .vscode, *.swp, Thumbs.db, etc.).
  • Dockerfile — bump NODE_VERSION from 22.11.0 to 22.20.0 (current Node 22 LTS).
  • README.md — update the --build-arg NODE_VERSION=... example to match the new default (was pointing at 20.18.0, never matched the Dockerfile).
  • opencode-user-config.json — lowercase the sentry MCP key for consistency with context7 and github.

2. Start OpenCode in ~/dev instead of /workspace (commit 0d28431)

Move the default working directory so the shell prompt and OpenCode worktree feel like a normal dev environment.

  • Dockerfile — create /home/developer/dev, set WORKDIR to it.
  • docker-entrypoint.shgit init ~/dev (so OpenCode anchors its worktree there) and cd into it; keep the /workspace ownership fix and /workspace/.opencode mkdir untouched.
  • README.md — document the new start dir and the persistence trade-off.

Persistence note: The Railway Volume still mounts at /workspace and OpenCode session/auth data still persists via the ~/.local/share/opencode -> /workspace/.opencode symlink. Files written under ~/dev are intentionally ephemeral — clone projects under /workspace if they need to survive redeploys.

Test plan

  • docker build -t my-opencode . succeeds with the new Node version.
  • Run locally: docker run --rm -it -p 4096:4096 --env-file .env my-opencode; verify shell starts in ~/dev and OpenCode treats it as the worktree.
  • /workspace/.opencode still gets created on first boot; sessions persist across container restarts when a volume is attached.

Aditya Mathur added 2 commits April 28, 2026 02:08
- .dockerignore: drop misleading Dockerfile entry (BuildKit handles it),
  add editor/OS noise patterns and explicit .env exclusion
- Dockerfile: bump NODE_VERSION 22.11.0 -> 22.20.0 (current Node 22 LTS)
- README: align build-arg example with the new default Node version
- opencode-user-config.json: lowercase the 'sentry' MCP key for
  consistency with 'context7' and 'github'
Move the default working directory from /workspace to ~/dev so the
shell prompt and OpenCode worktree feel like a normal dev environment.
The Railway Volume still mounts at /workspace and OpenCode session/auth
data still persists via the ~/.local/share/opencode -> /workspace/.opencode
symlink, but files written under ~/dev are intentionally ephemeral.

- Dockerfile: create /home/developer/dev, set WORKDIR to it, comment the
  ephemerality caveat.
- docker-entrypoint.sh: git init ~/dev (so OpenCode anchors its worktree
  there) and cd into it; keep the /workspace ownership fix and
  /workspace/.opencode mkdir untouched.
- README: document the new start dir and the persistence trade-off.
@MathurAditya724 MathurAditya724 changed the title chore: small repo cleanups chore: repo cleanups + start OpenCode in ~/dev Apr 28, 2026
OpenCode now starts in ~/dev (this PR's earlier change), so the
natural place to attach a Railway Volume is the same directory the
agent actually works in. This drops the /workspace indirection
entirely and collapses everything onto a single mount path.

Changes:

- Dockerfile: drop /workspace from `install -d`. Retarget the
  ~/.local/share/opencode symlink to /home/developer/dev/.opencode.
  Update the WORKDIR/EXPOSE comment block to describe the new
  single-volume model.

- docker-entrypoint.sh: chown / mkdir / git-init now all act on
  $DEV_DIR (~/dev) instead of /workspace. The chown still claims a
  fresh root-owned volume on first boot via passwordless sudo.

- README: "What's inside" and the Railway deploy step both updated
  to point at /home/developer/dev as the single Volume mount path.
  No more "ephemeral cwd vs persistent /workspace" trade-off; clones
  in ~/dev now persist by default if a Volume is attached.

Verified locally with a forced root-owned named volume mounted at
/home/developer/dev:
- entrypoint chowns to 1000:1000
- /path API reports worktree=/home/developer/dev, directory=/home/developer/dev
- /project/current reports vcs: git
- /global/health returns 200 over basic auth
- ~/.local/share/opencode -> /home/developer/dev/.opencode symlink intact
@MathurAditya724
MathurAditya724 merged commit 142e0e4 into main Apr 28, 2026
@MathurAditya724
MathurAditya724 deleted the chore/repo-cleanup branch April 28, 2026 02:28
MathurAditya724 added a commit that referenced this pull request May 1, 2026
- opencode-webhooks README: replace stale `x-email-from` header reference with JSON `from` field (finding #1).
- http.ts: rewrite MAX_BODY_BYTES comment (no longer about RFC822); add MAX_EMAIL_BODY_BYTES = 64 KB and an optional maxBytes arg to readBodyBytes; email handler now uses the tighter cap (finding #2).
- cloudflare-email-worker README: note that a malformed regex literal in ALLOWED_SENDERS will throw at module init and the worker won't start (finding #3).
- email handler: parseEmailEvent's `str` now throws on non-string for required fields (from/to/subject/message_id) so the 400 detail names the offending field instead of misleading 'missing' messages (finding #4).
- Test gap for email identity fallback chain tracked in #14; no tests added in this commit (finding #5).
MathurAditya724 added a commit that referenced this pull request May 1, 2026
… SIDECAR_URL → WEBHOOK_URL (#13)

* refactor(email-worker): wrangler.json, inline ALLOWED_SENDERS, rename SIDECAR_URL → WEBHOOK_URL

- Replace wrangler.toml with wrangler.json (with $schema reference for
  editor validation). TOML and JSON are both first-class wrangler
  config formats; JSON keeps the worker package consistent with the
  rest of the repo's config files (package.json, tsconfig.json,
  webhooks.json).
- Move ALLOWED_SENDERS out of wrangler vars and into a top-level
  TypeScript const at the head of src/index.ts. The allowlist is
  PR-reviewed code now (typed as readonly string[]), compiled once at
  module load (zero per-request parse overhead), and a malformed regex
  fails the deploy instead of silently dropping at runtime. The Env
  shape no longer needs an ALLOWED_SENDERS field.
- Rename SIDECAR_URL → WEBHOOK_URL in wrangler.json vars, the Env
  interface, and the fetch call. 'Sidecar' was misleading anyway —
  the plugin is in-process with opencode, not a sidecar process.
  WEBHOOK_URL clearly names what it points at: the plugin's
  /webhooks/email endpoint.

* feat(email): worker becomes dumb pipe — unconditional forward + JSON event

The Cloudflare Email Worker now does two things per inbound email:

  1. message.forward(env.FORWARD_TO) unconditionally (if set), so every
     email reaches the operator's real inbox preserving DKIM. Wrapped
     in try/catch so a misconfigured FORWARD_TO doesn't block webhook
     dispatch — failure is logged loudly and we continue.
  2. If the From address is in ALLOWED_SENDERS, build a small JSON
     event from the headers we route on (from, to, subject,
     message_id, in_reply_to, references, list_id, x_github_reason,
     x_github_sender), HMAC-sign it, and POST as application/json to
     WEBHOOK_URL.

The worker no longer parses RFC822 in the plugin path — it just hands
Cloudflare's already-parsed headers to the plugin verbatim. The body
is never sent at all (it never was used; canonical state comes from
the GitHub API).

Plugin side:
- handlers/email.ts: reads req.json() instead of parsing RFC822;
  validates the event shape; everything downstream (identity, synth,
  dispatch) is unchanged.
- email/identity.ts: accepts the EmailEvent JSON shape instead of an
  EmailHeaders object. Same regex matchers; same in-reply-to /
  references fallback chain.
- email/synthesize.ts: reads metadata directly from the event object.
- email/parse.ts: deleted (no more RFC822 parsing).

Other changes:
- wrangler.json: added FORWARD_TO var (optional) and
  observability.logs.enabled = true so 'wrangler tail' and the
  Cloudflare dashboard show structured logs.
- READMEs: updated wire format, architecture diagrams, failure-mode
  table on the worker side.

Verified: bun run typecheck passes for both packages; wrangler deploy
--dry-run accepts the new config with both vars bound.

* fix: review findings on PR #13 (dumb-pipe + wrangler.json)

- opencode-webhooks README: replace stale `x-email-from` header reference with JSON `from` field (finding #1).
- http.ts: rewrite MAX_BODY_BYTES comment (no longer about RFC822); add MAX_EMAIL_BODY_BYTES = 64 KB and an optional maxBytes arg to readBodyBytes; email handler now uses the tighter cap (finding #2).
- cloudflare-email-worker README: note that a malformed regex literal in ALLOWED_SENDERS will throw at module init and the worker won't start (finding #3).
- email handler: parseEmailEvent's `str` now throws on non-string for required fields (from/to/subject/message_id) so the 400 detail names the offending field instead of misleading 'missing' messages (finding #4).
- Test gap for email identity fallback chain tracked in #14; no tests added in this commit (finding #5).
MathurAditya724 added a commit that referenced this pull request Aug 5, 2026
The webhook gate dispatched events whose sender is the bot itself (e.g.
jared's own PR review submission on a jared-labeled PR). That woke a
container and booted Flue only for the in-container router to discard it
via skip condition #1 (sender == $ME) — a wasted dispatch per self action.

Mirror that skip at the Worker gate: drop events where sender == botLogin,
except check_suite / workflow_run (CI on the bot's own commits is
actionable and feeds fix-ci / mark-pr-ready), matching the router exception.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant